package com.zhiyou.service.impl;

import com.zhiyou.dao.LesseeMapper;
import com.zhiyou.entity.Lessee;
import com.zhiyou.entity.Rent;
import com.zhiyou.service.LesseeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
@Service
public class LesseeServiceImpl implements LesseeService {
    @Autowired
    LesseeMapper lesseeMapper;
    //获取全部租户信息
    @Override
    public List<Lessee> getAll() {
        return lesseeMapper.getAllAndStatusIsZone();
//        return lesseeMapper.selectAll();
    }
    //模糊查询
    @Override
    public List<Lessee> getLesseeLikeAll(String likes) {
        List<Lessee> likeAll = lesseeMapper.getLesseeLikeAll(likes);
        System.out.println(likeAll.toString());
        return likeAll;
    }
    //根据id查询租户信息
    @Override
    public Lessee selectLesseeById(Integer id) {
        return  lesseeMapper.selectByPrimaryKey(id);
    }
    //修改租户信息操作
    @Override
    public int updateLeessee(Lessee lessee) {
        int i = lesseeMapper.updateLesseeById(lessee);
        return i;
    }
    //假删除租户信息
    @Override
    public int deleteLessee(Integer id) {
        int i = lesseeMapper.deleteLesseeById(id);
        return i;
    }
    //新增租户信息
    @Override
    public int addLessee(Lessee lessee) {
        Date date=new Date();
        Timestamp timestamp=new Timestamp(date.getTime());
        lessee.setLAddtime(timestamp);
        int i=lesseeMapper.addLessee(lessee);
        return i;
    }
    //判断是否在租房
    @Override
    public List<Lessee> selectLesseeIsZuFangIng(Integer id) {
        return lesseeMapper.selectLesseeIsZuFangIng(id);
    }


}
